package app.server.project.main.service.db.dao.cfg;

import app.server.project.main.service.db.entity.cfg.RankCfgEntity;
import app.server.project.main.service.db.mapper.cfg.RankCfgMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import java.util.Objects;

/**
 * @author Administrator
 * @description 针对表【user_info(用户信息表)】的数据库操作Service实现
 * @createDate 2025-01-16 15:25:22
 */
@Repository
public class RankCfgDao extends ServiceImpl<RankCfgMapper, RankCfgEntity> {


    @Cacheable(key = "#rankId", cacheNames = "app.server.project.main.service.db.dao.RankCfgDao")
    public RankCfgEntity getRankById(int rankId) {
        var data = this.getById(rankId);
        if (Objects.isNull(data)) {
            //缓存没有,就往库中写入一条数据
            data = RankCfgEntity.of(rankId);
        }
        data.setSynDb(true);
        return data;
    }
}




